<?php

GaAPI_Autoloader::instance()->load('GaAPI_Objects_Common_Object');

class GaAPI_Objects_Campaign extends GaAPI_Objects_Common_Object {

    public $id;
    public $name;
    public $endDate;
    public $status;
    public $biddingStrategy;
    public $budget;


    /**
     * @return GaAPI_Objects_Campaign_Budget
     */
    public function newBudget() {
        GaAPI_Autoloader::instance()->load('GaAPI_Objects_Campaign_Budget');
        $budget = new GaAPI_Objects_Campaign_Budget();
        return $budget;
    }

    /**
     * @return GaAPI_Objects_Campaign_Selector
     */
    public function newSelector() {
        GaAPI_Autoloader::instance()->load('GaAPI_Objects_Campaign_Selector');
        $selector = new GaAPI_Objects_Campaign_Selector();
        $selector->setClient($this->getClient());
        return $selector;
    }

    public function  __toString() {
        $xml = '';
        $xml .= '<name>' . $this->name . '</name>';
        $xml .= '<endDate>' . ($this->endDate ? $this->endDate : '') . '</endDate>';
        $xml .= '<status>' . $this->status . '</status>';
        $xml .= '<biddingStrategy xsi:type="' . $this->biddingStrategy . '"/>';
        $xml .= '<budget>' . $this->budget . '</budget>';
        return $xml;
    }

}